'use strict';

module.exports = app => {
  const { STRING, INTEGER, TEXT, DATE } = app.Sequelize;

  const Article = app.model.define('article', {
    id: { type: INTEGER, primaryKey: true, autoIncrement: true },
    type: {
      type: STRING(255),
      allowNull: false,
      unique: true, // 添加唯一约束
      comment: '文章类型，每种类型只能有一条数据'
    },
    content: TEXT,
    status: {
      type: INTEGER,
      defaultValue: 1, // 1: 正常, 0: 禁用
      comment: '状态：1-正常，0-禁用'
    },
    created_at: DATE,
    updated_at: DATE,
  }, {
    tableName: 'articles',
    timestamps: true,
    indexes: [
      {
        unique: true,
        fields: ['type'],
      },
    ],
  });

  return Article;
}; 